C Programming Made Easy: A beginner's guide by Abhijit Zingade
Author:Abhijit Zingade [Zingade, Abhijit]
Language: eng
Format: azw3
Published: 2017-10-18T04:00:00+00:00
void main()
{
int no1,no2,result;
clrscr();
printf("\n Enter the first number");
scanf("%d",&no1);
printf("\n Enter the second number");
scanf("%d",&no2);
result=add(no1,no2);
printf("\n The addition of two numbers is %d",result);
getch();
}
int add(int number1,int number2)
{
int answer;
answer=number1+number2;
return answer;
}
Program Output : -
Enter the first number40
Enter the second number60
The addition of two numbers is 100
Now we will discuss each concept defined in the program. Before starting keep in mind that we are going to discuss more than one concept throughout this program. Those concepts are header files, function prototype declaration for user defined function, main() function, declaring the variables, Using the inbuilt functions, function calling ( In function calling we will discuss the difference between calling function and called function), parameter passing, parameter catching, returning parameter and finally displaying the result and terminate the program.
In our program very first line is about the header files. That is we declared here two header files named stdio.h and conio.h. These are the header files created by the compiler. And we only use that in our program. Generally the inbuilt functions like printf() and scanf() are defined in stdio.h. stdio means standard input and output. Whenever we have to do input output related operations then we use stdio.h header file.
The functions clrscr() and getch() are defined in conio.h header file. conio is nothing but console input and output. It will do the console related operations like clearing the screen and stopping the output screen to validate the output.
Function prototype is nothing but the definition about the function. Here we use to write the functions with its all characteristics. In our program we have declared int add(int,int). Which demonstrate the add function is the user defined function which is returning the value as int. Also add is the name of function. Then finally in rounding bracket we have written (int, int) it means that our program is able to catch two integer values from the other function which are calling the add function.
After that we have declared the main() function. Main() function is the important function in C language. Because the execution of any program will start from main () function. So we have declared the main function. Generally the main function is not returning any value therefore the return type of main function is void. Also main function is not taking any parameters so in rounding brackets of main function we don’t have any parameters.
After that we have declared the variables. The variables are no1, no2 and result. All variables declared in main function are of integer type.
As we have discussed here we have used the inbuilt functions like printf and scanf. printf is a function which is used to print the values placed in rounding brackets.
Now in our program the main and important thing related to function comes. That is,
result=add(no1,no2); //statement.
In above statement we have written add(no1,no2). Now this statement is called as calling statement. Because by using this statement we are calling the add function. And basically the calling statement add(no1,no2) is written in main() function therefore the main function is called as calling function.
When actually program calls
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(26287)
Hello! Python by Anthony Briggs(25212)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(24440)
Kotlin in Action by Dmitry Jemerov(23531)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(22873)
Dependency Injection in .NET by Mark Seemann(22661)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(21423)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(20266)
Grails in Action by Glen Smith Peter Ledbrook(19337)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17050)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(16362)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(14074)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(12248)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11527)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10639)
Hit Refresh by Satya Nadella(9216)
The Kubernetes Operator Framework Book by Michael Dame(8576)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8429)
Robo-Advisor with Python by Aki Ranin(8372)